#include "PlayerFactory.h"


PlayerFactory::PlayerFactory(void)
{

}


PlayerFactory::~PlayerFactory(void)
{

}

Boxer* PlayerFactory::CreateBoxer()
{
	return new Player();
}

char* PlayerFactory::SetName()
{
	std::cout <<std::endl<<"Inserisci nome e cognome del tuo pugile: ";
	char *name = new char[50];
	char *surname = new char[50];
	char *nameSurname= new char[100];
	std::cin >> name >> surname;
	strcpy(nameSurname,name);
	strcat(nameSurname, " ");
	strcat(nameSurname, surname);
	return nameSurname;
}

 int PlayerFactory::SetSkills(Boxer *aB, skill aSkillMaxPoint)
 {
	SkillType skillType= STRENGTH;
	unsigned points;
	aB->mSkills[STRENGTH]=aB->mSkills[RESISTANCE]=aB->mSkills[SPEED]=aB->mSkills[REFLEX]=0;
	do{
		std::cout <<std::endl<<"Punti da assegnare: " << aSkillMaxPoint <<std::endl;
		switch(skillType){
			case STRENGTH:
				std::cout <<std::endl<<"Assegna punti per STRENGTH: "<<std::endl;

				if( !(std::cin >> points) || points>aSkillMaxPoint)
				{
					std::cin.clear();
					std::cin.ignore();
					std::cout <<std::endl<<"Valore non valido"<<std::endl;
				}
				else
				{
					aB->mSkills[skillType]=points;
					skillType=RESISTANCE;
					aSkillMaxPoint=aSkillMaxPoint-points;
				}
				break;
			case RESISTANCE:
				std::cout <<std::endl<<"Assegna punti per RESISTANCE: "<<std::endl;
				if( !(std::cin >> points) || points>aSkillMaxPoint)
				{
					std::cout <<std::endl<<"Valore non valido"<<std::endl;
				}
				else
				{
					aB->mSkills[skillType]=points;
					skillType=SPEED;
					aSkillMaxPoint=aSkillMaxPoint-points;
				}
				break;
			case SPEED:
				std::cout <<std::endl<<"Assegna punti per SPEED: "<<std::endl;
				if( !(std::cin >> points) || points>aSkillMaxPoint)
				{
					std::cout <<std::endl<<"Valore non valido"<<std::endl;
				}
				else
				{
					aB->mSkills[skillType]=points;
					skillType=REFLEX;
					aSkillMaxPoint=aSkillMaxPoint-points;
				}
				break;
			case REFLEX:
				std::cout <<std::endl<<"Punti REFLEX: "<<aSkillMaxPoint<<std::endl;
				aB->mSkills[skillType]=aSkillMaxPoint;
				aSkillMaxPoint=0;
				break;
		}
	}
	while(aSkillMaxPoint);
	return 1;
 }